package com.xubeizhi.controller;

import com.xubeizhi.common.Result;
import com.xubeizhi.entity.Category;
import com.xubeizhi.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RequestMapping("/category")
@RestController
public class CategoryController {

    @Autowired
    private CategoryService categoryService;


    @PostMapping("/create")
    private Result createCategory(@RequestBody Category category){
        return categoryService.createCategory(category);
    }

    @PostMapping("/update")
    private Result updateCategory(@RequestBody Category category){
        return categoryService.updateCategory(category);
    }

    @PostMapping("/remove")
    private Result removeCategory(@RequestBody Category category){
        return categoryService.removeCategory(category);
    }

    @PostMapping("/sold")
    private Result soldCategory(Category category){
        return categoryService.soldCategory(category);
    }

    @GetMapping("/list")
    private Result listCategory(Integer pageNum, Integer pageSize, @RequestParam(required = false) String status, @RequestParam(required = false) String removeStatus){
        return categoryService.listCategory(pageNum,pageSize,status,removeStatus);
    }
}
